package leetcode;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/**
 * @author Retain
 * @date 2021/8/1 15:59
 */
public class Pool {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String s = br.readLine();
        String[] split = s.substring(s.indexOf('[') + 1, s.indexOf(']')).split(",");
        int[] rains = new int[split.length];
        for (int i = 0; i < split.length; i++) {
            rains[i] = Integer.parseInt(split[i]);
        }
        int[] ans = new int[split.length];
        boolean flag = false;
        for (int i = 0; i < split.length; i++) {
            if (rains[i] > 0) {
                ans[i] = -1;
            }else {
                flag = true;
                int pool = searchFirstPoolWithRain(rains);
                rains[i] = 0;
                ans[i] = rains[pool];
            }
        }
        // 不能阻止
        if (flag) {
            System.out.println("[]");
        }else {
            System.out.print("[");
            for (int i = 0; i < ans.length - 1; i++) {
                System.out.print(ans[i] + ",");
            }
            System.out.print(ans[ans.length - 1] + "]");
            System.out.println();
        }
    }

    private static int searchFirstPoolWithRain(int[] rains) {
        if (rains != null) {
            for (int i = 0; i < rains.length; i++) {
                if (rains[i] != 0) {
                    return i;
                }
            }
        }
        return -1;
    }
}
